The present invention relates to an information processing apparatus and method for managing files stored on a storage medium, and a computer readable memory.
A file system that manages files using a FAT (File Allocation Table) is generally called a FAT file system. A disk medium formatted for use in such FAT file system is called a FAT disk.
FIG. 13 shows an example of the recording format of a FAT disk mainly used in MS-DOS/MS-Windows/MS-Windows 95, 98/MS-Windows NT as the operating system offered by Microsoft Corp.
Not only a FAT disk but also a storage medium called a xe2x80x9cdiskxe2x80x9d are segmented into a plurality of blocks in units of sectors, and data recorded on a disk is read/written in units of sectors. Normally, data for 512 bytes or 1,024 bytes can be recorded per sector.
Reference numeral 1301 denotes one start sector (logical sector number=0), which is normally called a boot sector. The boot sector 1301 records a boot program for loading the operating system, and information such as the numbers of sectors that form a FAT, root directory entry, and the like (to be described later).
Reference numeral 1302 denotes a FAT which is an area for recording the allocation state of clusters to a file. Two FATs 1302 are prepared, as shown in FIG. 13 (FAT1 and FAT2 in FIG. 13), and are successively allocated on the disk. That is, FAT1 and FAT2 always have the same recorded contents.
Reference numeral 1303 denotes a root directory entry. One item of root directory entry 1303 consists of 32 bytes, and the respective items record information such as the names of files and directories (sub directories) present under the root directory of the FAT disk, file sizes (unit: byte), numbers of clusters (start cluster numbers) that record start data in files of clusters that record the contents (data main body) of actual files corresponding to files on the directory entry in a data area (to be described later), and the like.
Reference numeral 1304 denotes a data area for recording the contents (data main body) of actual files, and information that pertains to sub sdirectories. The data area 1304 is managed in units of clusters. Each cluster has a plurality of successive sectors as one unit, and one cluster is made up of sectors, the number of which is expressed by powers of 2 (1, 2, 4, 8, 16, . . . ,). In the following description, assume that one cluster is made up of one sector for the sake of simplicity.
FIG. 14 shows the contents recorded on the area of the FAT 1302 in FIG. 13. Respective items 1402 of the FAT 1302 have one-to-one correspondence with cluster addresses 1403 of the data area 1304. The items 1402 of the FAT 1302 are used to record the order of clusters (FAT chain) so that clusters that form a given file can be read out in a normal order upon reading out that file. That is, the contents of each item 1402 record the value of the next cluster address to be read out in turn, and record a value (e.g., FFFFh) indicating the last cluster for the last cluster of data. In this manner, clusters that form a file can be joined in a correct order.
A detailed explanation will be given with reference to FIG. 14. For example, if a start cluster address 1401 of a given file present under the root directory is 0004h based on information recorded in the root directory entry 1303, since a value xe2x80x9c0005hxe2x80x9d is written in the (0004h)-th FAT item 1402, it is determined that the subsequent data (xe2x80x98bxe2x80x99 of 1403) is recorded at the (0005h)-th cluster address of the data area 1304. Likewise, since a value xe2x80x9c000Ahxe2x80x9d is written in the (0005h)-th FAT item 1402, it is determined that the next subsequent data (xe2x80x98cxe2x80x99 of 1403) is recorded at the (000Ah)-th cluster address. Since a value xe2x80x9cFFFFhxe2x80x9d indicating the end of a FAT chain is written in the (000Ah)-th FAT item 1402, the (000Ah)-th cluster address in the data area 1304 is the one that contains the last data. Note that a FAT item 1402 which corresponds to a cluster (free cluster) which is not used by any file of those in the data area 1304 is written with 0000h as a value indicating free.
The flow of processes upon opening a file present on a FAT disk and reading/writing data of that file in the conventional FAT file system will be explained below. For the sake of simplicity, assume that a file which is to undergo read/write is present under the root directory, and a description of an error process will be omitted.
A file read process will be explained first.
When a given user program designates a file name and a read of that file is requested (file open), data of the root directory entry 1303 is read out first to search for an entry that contains the file name which matches the file name designated by the user program. If an entry that matches the designated file name is found, the start cluster address and file size in the data area 1304 where a data main body is recorded are acquired from that entry item. Upon reading actual file data recorded at the start cluster address of the data area 1304, the area of the aforementioned FAT 1302 is read out to interpret data of the FAT item recorded at the position corresponding to the start cluster address to compute the cluster address where the subsequent file data is recorded. Likewise, the FAT chain is followed to have the start cluster address as the start point and to read out file data in turn until the cluster address that contains the last data is reached.
A new file create process of the data write process will be explained below.
When a file open request is issued, data in the root directory entry 1303 is read out to confirm if the given file name overlaps the one already present on the root directory entry 1303. If the file name does not overlap, directory entries for this new file are created on the root directory entry 1303. Data of FAT items of the FAT 1302 are read out to search for a FAT item that records a free (0000h) value. If a FAT item that records a free value is found, required data is written at the corresponding cluster address in the data area 1304. At the same time, the value of the FAT item corresponding to the cluster address found as a free cluster in the FAT 1302 is rewritten from xe2x80x9cfreexe2x80x9d (0000h) to a xe2x80x9cpart of filexe2x80x9d (FFFFh). When write data in the data area 1304 cannot fall within one cluster, the FAT 1302 is searched for a FAT item that records a free value, and data is written at the cluster address in the data area 1304 corresponding to that FAT item. At the same time, the value of the FAT item corresponding to the cluster address found as a free cluster is rewritten to FFFFh. At this time, the value of the FAT item corresponding to the cluster address found in the immediately preceding process is rewritten from FFFFh to the cluster address found in the current process. By repeating this sequence, the arrangement order of clusters is recorded in turn, thus completing a FAT chain.
With the aforementioned sequence, after all data have been written in the data area 1304 and the FAT chain have been written in the FAT 1302, pieces of information such as the new file name, start cluster address, file size, and the like are finally recorded in the directory entries for the new file assured previously. In this way, creation of a new file is completed.
In a data additional write process to an existing file, upon receiving a file open request, the FAT chain is followed in turn on the basis of the start cluster address and data in the FAT 1302 to obtain the cluster address at which the last data is recorded, as in the file read process. In this cluster, existing data is written halfway through the cluster size. Hence, data to be additionally written is written after the end of data stored halfway through the cluster. When the data to be additionally written overflows that cluster, the FAT 1302 is searched for a FAT item that records a free value, and the data is written in the corresponding free cluster in the data area 1304. At the same time, the contents of the corresponding FAT item are rewritten to complete the FAT chain.
Finally, information such as the file size after data additional write or the like is recorded in the root directory entry 1303.
In a data overwrite process on an existing file, required data is overwritten on clusters in the data area 1304 corresponding to FAT items in turn from the start cluster address in accordance with the arrangement order of clusters obtained from the current FAT chain. At this time, when the data size of the existing file is larger than that of the overwrite file, xe2x80x9cFFFFhxe2x80x9d is written in the value of a FAT item corresponding to the last cluster of the data of the overwrite file. On the other hand, xe2x80x9c0000hxe2x80x9d indicating a free cluster is written in the value of a FAT item corresponding to each remaining cluster that does not store any overwrite data in the FAT chain before overwrite. On the contrary, when the data size of the overwrite file is larger than that of the existing file, after required data is written in all the clusters obtained from the FAT chain before overwrite, the FAT 1302 is searched for a FAT item that records a free value, and data is written in a free cluster in the data area 1304 corresponding to that FAT item, in the same manner as in the data additional write process to the existing file.
Finally, information such as the file size after data overwrite or the like is recorded in the root directory entry 1303.
However, in the method of recording and managing the state of clusters allocated to a given file in the FAT 1302 as in the conventional FAT file system, the FAT 1302 and data area 1304 are separated. Since clusters that record the data main body of a given file are scattered on the data area 1304, when the file is to be read out, processes for reading out the corresponding FAT item and computing the next cluster to be read out must be done every time data for one cluster is read out from the data area 1304. Also, when data is written in a file, FAT items scattered on the FAT 1302 must be searched to find a cluster in which data is to be written. In this way, since the conventional FAT file system follows the FAT chain based on each pointer to the next cluster address recorded in the FAT 1302, a heavy load is imposed on a file read/write process, and that process is time-consuming.
The present invention has been made in consideration of the aforementioned problems, and has as its object to provide an information processing apparatus and method, which can access data stored on a storage medium at high speed, and a computer readable memory.
In order to achieve the above object, an information processing apparatus according to the present invention comprises the following arrangement. That is, an information processing apparatus for managing a file stored on a storage medium, comprises:
management means for storing and managing storage position information indicating a storage position of one file in a predetermined storage area in a directory entry that stores information which pertains to the file; and
execution means for executing access to the file by looking up the directory entry managed by the management means.
Preferably, the management means also stores and manages the storage position information in a dedicated storage area on the storage medium, which stores a file management table for managing the storage position of the file.
Preferably, the predetermined storage area is allocated immediately before an area that stores a file name of the file.
Preferably, the management means stores and manages the storage position information of a portion that exceeds a size of the predetermined storage area in the dedicated storage area when the storage position information to be managed and stored exceeds the size of the predetermined storage area.
Preferably, the management means appends an index indicating that the predetermined storage area stores the storage position information to a head of the predetermined storage area.
Preferably, the execution means preferentially looks up the storage position information of the file stored in the directory entrywhen access to the file is instructed.
In order to achieve the above object, an information processing method according to the present invention comprises the following arrangement. That is, an information processing method for managing a file stored on a storage medium, comprises:
the management step of storing and managing storage position information indicating a storage position of one file in a predetermined storage area in a directory entry that stores information which pertains to the file; and
the execution step of executing access to the file by looking up the directory entry managed in the management step.
In order to achieve the above object, a computer readable memory according to the present invention comprises the following arrangement. That is, a computer readable memory that stores a program code of information processing for managing a file stored on a storage medium, comprises:
a program code of the management step of storing and managing storage position information indicating a storage position of one file in a predetermined storage area in a directory entry that stores information which pertains to the file; and
a program code of the execution step of executing access to the file by looking up the directory entry managed in the management step.
Other features and advantages of the present invention will be apparent from the following description taken in conjunction with the accompanying drawings, in which like reference characters designate the same or similar parts throughout the figures thereof.